package com.tanhua.server.controller;

import com.tanhua.domain.vo.RecommendUserQueryParam;
import com.tanhua.server.service.BaiduService;
import com.tanhua.server.service.RecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class TanhuaController {

    @Autowired
    private RecommendService recommendService;
    @Autowired
    private BaiduService baiduService;

    @GetMapping(value = "/todayBest",name = "查询今日佳人")
    public ResponseEntity queryTodayBest(){
        return recommendService.queryTodayBest();
    }

    @GetMapping(value = "/recommendation",name = "分页查询推荐佳人")
    public ResponseEntity queryRecommendation(RecommendUserQueryParam param){
        return recommendService.queryRecommendation(param);
    }

    @GetMapping(value = "/{id}/personalInfo",name = "查看佳人详细信息")
    public ResponseEntity queryPersonalInfo(@PathVariable("id") Long userId){
        return recommendService.queryPersonalInfo(userId);
    }

    @GetMapping(value = "/strangerQuestions",name = "查看指定用户设置的陌生人问题")
    public ResponseEntity queryStrangerQuestions(Long userId){
        return recommendService.queryStrangerQuestions(userId);
    }


    @PostMapping(value = "/strangerQuestions",name = "回复陌生人问题")
    public ResponseEntity replyStrangerQuestions(@RequestBody Map map){
        Long userId =  Long.parseLong( map.get("userId").toString());
        String reply = (String) map.get("reply");
        return recommendService.replyStrangerQuestions(userId,reply);
    }

    @GetMapping(value = "/cards",name = "左滑右滑卡片展示")
    public ResponseEntity cards(){
        return recommendService.cards(20);
    }

    @GetMapping(value = "/{id}/love",name = "右滑喜欢")
    public ResponseEntity love(@PathVariable("id") Long likeUserId){
        return recommendService.love(likeUserId);
    }

    @GetMapping(value = "/{id}/unlove",name = "右滑喜欢")
    public ResponseEntity unlove(@PathVariable("id") Long likeUserId){
        return recommendService.unlove(likeUserId);
    }


    @GetMapping(value = "/search",name = "搜附近的人")
    public ResponseEntity search(String gender,Integer distance){
        return baiduService.search(gender,distance);
    }

}
